﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using DataLib.Common;
using DataLib.Accounts.Bus;

namespace Ewts.BaseData
{
    public partial class GoodsAdd : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnSave_Click(object sender, EventArgs e)
        {

            string strErr = "";
            string goodsName = txtgoodsName.Text.Trim();
            string describe = this.txtdescribe.Text.Trim();
            DataLib.BLL.Goods bll = new DataLib.BLL.Goods();
            if (goodsName.Length == 0)
            {
                strErr += "物品代码不能为空！\\n";
            }
            else if (describe.Length == 0)
            {
                strErr += "物品名称不能为空！\\n";
            }
            else
            {
                if (bll.GetgoodsID(goodsName) != 0)
                    strErr += "物品编码已经存在";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            
            string goodsType = this.ddlgoodsType.SelectedValue;
            string remark = txtRemark.Text;
            DataLib.Model.Goods model = new DataLib.Model.Goods();
            model.goodsName = goodsName;
            model.goodsType = goodsType;
            model.describe = describe;
            model.remark = remark;
            model.isHw = false;


         
            bll.Add(model);
            DataLib.Common.MessageBox.ShowAndRedirect(this, "保存成功！", "GoodsAdd.aspx");

        }


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("GoodsList.aspx");
        }
    }
}
